<% layout('/layouts/default.html', {title: '用户表管理', libs: ['dataGrid']}){ %>
<div class="main-content">
	<div class="box box-main">
		<div class="box-header">
			<div class="box-title">
				<i class="fa fa-list-alt"></i> ${text('用户表管理')}
			</div>
			<div class="box-tools pull-right">
				<a href="#" class="btn btn-default" id="btnSearch" title="${text('查询')}"><i class="fa fa-filter"></i> ${text('查询')}</a>
				<a href="#" class="btn btn-default" id="btnExport" title="${text('导出数据')}"><i class="fa fa-filter"></i> ${text('导出数据')}</a>
				<% if(hasPermi('wx:wxUser:edit')){ %>
					<!--<a href="${ctx}/wx/wxUser/form" class="btn btn-default btnTool" title="${text('新增用户表')}"><i class="fa fa-plus"></i> ${text('新增')}</a>-->
				<% } %>
			</div>
		</div>
		<div class="box-body">
			<#form:form id="searchForm" model="${wxUser}" action="${ctx}/wx/wxUser/listData" method="post" class="form-inline"
					data-page-no="${parameter.pageNo}" data-page-size="${parameter.pageSize}" data-order-by="${parameter.orderBy}">
				<!--<div class="form-group">-->
					<!--<label class="control-label">${text('user_name')}：</label>-->
					<!--<div class="control-inline">-->
						<!--<#form:input path="userName" maxlength="200" class="form-control width-120"/>-->
					<!--</div>-->
				<!--</div>-->
				<div class="form-group">
					<label class="control-label">${text('微信昵称')}：</label>
					<div class="control-inline">
						<#form:input path="nickName" maxlength="200" class="form-control width-120"/>
					</div>
				</div>
				<!--<div class="form-group">-->
					<!--<label class="control-label">${text('age')}：</label>-->
					<!--<div class="control-inline">-->
						<!--<#form:input path="age" maxlength="11" class="form-control width-120"/>-->
					<!--</div>-->
				<!--</div>-->
				<!--<div class="form-group">-->
					<!--<label class="control-label">${text('create_date')}：</label>-->
					<!--<div class="control-inline">-->
						<!--<#form:input path="createDate" class="form-control width-120"/>-->
					<!--</div>-->
				<!--</div>-->
				<!--<div class="form-group">-->
					<!--<label class="control-label">${text('update_date')}：</label>-->
					<!--<div class="control-inline">-->
						<!--<#form:input path="updateDate" class="form-control width-120"/>-->
					<!--</div>-->
				<!--</div>-->
				<!--<div class="form-group">-->
					<!--<label class="control-label">${text('status')}：</label>-->
					<!--<div class="control-inline width-120">-->
						<!--<#form:select path="status" dictType="sys_search_status" blankOption="true" class="form-control"/>-->
					<!--</div>-->
				<!--</div>-->
				<!--<div class="form-group">-->
					<!--<label class="control-label">${text('remarks')}：</label>-->
					<!--<div class="control-inline">-->
						<!--<#form:input path="remarks" maxlength="200" class="form-control width-120"/>-->
					<!--</div>-->
				<!--</div>-->
				<!--<div class="form-group">-->
					<!--<label class="control-label">${text('wx_open_id')}：</label>-->
					<!--<div class="control-inline">-->
						<!--<#form:input path="wxOpenId" maxlength="500" class="form-control width-120"/>-->
					<!--</div>-->
				<!--</div>-->
				<div class="form-group">
					<label class="control-label">${text('手机号')}：</label>
					<div class="control-inline">
						<#form:input path="phone" maxlength="200" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label col-sm-4">选择活动：</label>
					<div class="col-sm-8">
						<#form:treeselect id="getActivityListByOrg" title="选择活动"
						path="activityId" labelPath="title"
						url="${ctx}/wx/wxActivity/treeData" allowClear="true"/>
					</div>
				</div>
				<!--<div class="form-group">-->
					<!--<label class="control-label">${text('city')}：</label>-->
					<!--<div class="control-inline">-->
						<!--<#form:input path="city" maxlength="200" class="form-control width-120"/>-->
					<!--</div>-->
				<!--</div>-->
				<!--<div class="form-group">-->
					<!--<label class="control-label">${text('sex')}：</label>-->
					<!--<div class="control-inline">-->
						<!--<#form:input path="sex" maxlength="11" class="form-control width-120"/>-->
					<!--</div>-->
				<!--</div>-->
				<div class="form-group">
					<button type="submit" class="btn btn-primary btn-sm">${text('查询')}</button>
					<button type="reset" class="btn btn-default btn-sm">${text('重置')}</button>
				</div>
			</#form:form>
			<table id="dataGrid"></table>
			<div id="dataGridPage"></div>
		</div>
	</div>
</div>
<% } %>
<script>
// 初始化DataGrid对象
$('#dataGrid').dataGrid({
	searchForm: $("#searchForm"),
	columnModel: [
		{header:'${text('微信昵称')}', name:'nickName', index:'a.nick_name', width:150, align:"left", frozen:true, formatter: function(val, obj, row, act){
			return '<a href="${ctx}/wx/wxUser/form?id='+row.id+'" class="btnList" data-title="${text('编辑用户表')}">'+(val||row.id)+'</a>';
		}},
		{header:'${text('真实姓名')}', name:'userName', index:'a.user_name', width:150, align:"center"},
		{header:'${text('头像')}', name:'nickName', index:'a.nick_name', width:100, align:"center", frozen:true, formatter: function(val, obj, row, act){
			return '<img src="'+row.headImg+'" style="width: 50px;height: 50px">';
		}},
		{header:'${text('手机号')}', name:'phone', index:'a.phone', width:150, align:"center"},
		// {header:'${text('年龄')}', name:'age', index:'a.age', width:150, align:"center"},
		// {header:'${text('status')}', name:'status', index:'a.status', width:150, align:"center", formatter: function(val, obj, row, act){
		// 	return js.getDictLabel(${@DictUtils.getDictListJson('sys_search_status')}, val, '${text('未知')}', true);
		// }},
		// {header:'${text('wx_open_id')}', name:'wxOpenId', index:'a.wx_open_id', width:150, align:"left"},
		// {header:'${text('联系方式')}', name:'phone', index:'a.phone', width:150, align:"left"},
		{header:'${text('城市')}', name:'city', index:'a.city', width:150, align:"left"},
		// {header:'${text('性别')}', name:'sex', index:'a.sex', width:150, align:"center"},
        // {header:'${text('备注')}', name:'remarks', index:'a.remarks', width:150, align:"left"},
        {header:'${text('登录时间')}', name:'createDate', index:'a.create_date', width:150, align:"center"},
        {header:'${text('返佣金额')}', name:'disMoneyValue', index:'a.dis_money_value', width:150, align:"center"},
        {header:'${text('活动推广')}', name:'actions', width:120, align:"center",sortable:false, title:false, formatter: function(val, obj, row, act){
			var actions = [];
			<% if(hasPermi('wx:wxUser:edit')){ %>
				actions.push('<a href="${ctx}/wx/wxUserDisValueRecord/wxDisSpreadList/?userId='+row.id+'&buyActivityId='+row.attendActivityIds+'" class="btnList" title="${text('查看推广')}">查看明细</a>&nbsp;');
			<% } %>
			return actions.join('');
		}},
		{header:'${text('查看上级')}', name:'actions', width:120, align:"center",sortable:false, title:false, formatter: function(val, obj, row, act){
			var actions = [];
			<% if(hasPermi('wx:wxUser:edit')){ %>
				actions.push('<a href="${ctx}/wx/wxUserDisValueRecord/wxParentDisList/?buyUserId='+row.id+'&buyActivityId='+row.attendActivityIds+'" class="btnList" title="${text('查看上级')}">查看上级</a>&nbsp;');
			<% } %>
			return actions.join('');
		}},
		// {header:'${text('返佣明细')}', name:'actions', width:120, align:"center",sortable:false, title:false, formatter: function(val, obj, row, act){
		// 	var actions = [];
		// 	<% if(hasPermi('wx:wxUser:edit')){ %>
		// 		actions.push('<a href="${ctx}/wx/wxUserDisValueRecord/wxDisDetailList/?userId='+row.id+'&buyActivityId='+row.attendActivityIds+'" class="btnList" title="${text('查看返佣明细')}">'+row.disMoneyValue+'</a>&nbsp;');
		// 	<% } %>
		// 	return actions.join('');
		// }},
		{header:'${text('操作')}', name:'actions', width:120, sortable:false, title:false, formatter: function(val, obj, row, act){
			var actions = [];
			<% if(hasPermi('wx:wxUser:edit')){ %>
				actions.push('<a href="${ctx}/wx/wxUser/form?id='+row.id+'" class="btnList" title="${text('编辑用户表')}"><i class="fa fa-pencil"></i></a>&nbsp;');
				actions.push('<a href="${ctx}/wx/wxUser/delete?id='+row.id+'" class="btnList" title="${text('删除用户表')}" data-confirm="${text('确认要删除该用户表吗？')}"><i class="fa fa-trash-o"></i></a>&nbsp;');
			<% } %>
			return actions.join('');
		}}
	],
	// 加载成功后执行事件
	ajaxSuccess: function(data){
		console.log(data);
	}
});
</script>
<script>
    $('#btnExport').click(function(){
        var activityId = $('#getActivityListByOrgCode').val()
		alert(activityId)
        js.ajaxSubmitForm($('#searchForm'), {
            url:'${ctx}/wx/wxUser/exportData?exportActivityId='+activityId+'',
            downloadFile:true
        });
    });
</script>